#!/usr/bin/python

# InnerSpace
# Copyright (C) 1999-2006 Phil Christensen
#
# $Id: minimal.py 154 2007-02-11 01:20:42Z phil $
#
# See LICENSE for details

"""
This creates a minimal database of objects and verbs from a supplied,
presumed empty registrty object.

Other core packages may not require an empty database, and in fact, this
one would just add a number of objects and verbs to an existing registry,
but the use of a "used" registry is not reccomended.
"""
from inner.space import entity, security
import os.path

def init(registry, datadir):
	system_object = registry.get(0)
	
	class_wizard = registry.new(u"class_wizard", unique=True)
	class_programmer = registry.new(u"class_programmer", unique=True)
	class_author = registry.new(u"class_author", unique=True)
	class_player = registry.new(u"class_player", unique=True)
	class_room = registry.new(u"class_room", unique=True)
	class_door = registry.new(u"class_door", unique=True)
	
	wizard = registry.new(u"wizard", unique=True)
	phil = registry.new(u"phil", unique=True)
	
	mask = registry.new(u"mask")
	room = registry.new(u"The Classroom")
	
	class_wizard.set_location(room)
	class_wizard.set_owner(wizard)
	
	class_author.set_location(room)
	class_author.set_owner(wizard)
	
	class_player.set_location(room)
	class_player.set_owner(wizard)
	
	class_programmer.set_location(room)
	class_programmer.set_owner(wizard)
	
	class_room.set_location(room)
	class_room.set_owner(wizard)
	
	class_wizard.set_parent(class_programmer)
	class_programmer.set_parent(class_author)
	class_author.set_parent(class_player)

	phil.set_player()
	phil.set_location(room)
	phil.add_property(u'passwd', u'phil', wizard)
	phil.set_owner(phil)
	phil.set_parent(class_player)
	
	wizard.set_wizard()
	wizard.set_location(room)
	wizard.add_property(u'passwd', u'wizard', wizard)
	wizard.set_owner(wizard)
	wizard.set_parent(class_wizard)
	
	mask.set_location(room)
	
	room.set_parent(class_room)
	
	room.add_property(u'description',
					  u'A bunch of stuff is in this room, like a <A HREF="ispace:look+mask">mask</A>...',
					  wizard,
					  acl_configure=security.readable_property_acl)
	
	room.add_property(u'image',
					  u'http://bubblehouse.org/space/firstroom.jpg',
					  wizard,
					  acl_configure=security.readable_property_acl)

	system_object.add_property(u'default_player_class',
							   class_player,
							   wizard,
							   acl_configure=security.readable_property_acl)

	system_object.add_property(u'default_room_class',
							   class_room,
							   wizard,
							   acl_configure=security.readable_property_acl)

	system_object.add_property(u'default_owner',
							   wizard,
							   wizard,
							   acl_configure=security.readable_property_acl)

	registry.load_verb(class_room, os.path.join(datadir, 'room_get_observations.py'), [u'get_observations'], class_wizard, is_method=True)
	registry.load_verb(system_object, os.path.join(datadir, 'sys_get_observations.py'), [u'get_observations'], class_wizard, is_method=True)
	registry.load_verb(class_door, os.path.join(datadir, 'door_enter.py'), [u'enter'], class_wizard, is_method=True)
	registry.load_verb(class_player, os.path.join(datadir, 'player_look.py'), [u"look", u"inspect", u"examine"], class_wizard, is_ability=True)
	registry.load_verb(class_player, os.path.join(datadir, 'player_go.py'), [u"go"], class_wizard, is_ability=True)
	registry.load_verb(class_player, os.path.join(datadir, 'player_say.py'), [u"say"], class_wizard, is_ability=True)
	registry.load_verb(class_player, os.path.join(datadir, 'player_hear.py'), [u"hear"], class_wizard, is_method=True)
	registry.load_verb(class_player, os.path.join(datadir, 'player_take.py'), [u'take', u'get', u'grab'], class_wizard, is_ability=True)
	registry.load_verb(class_player, os.path.join(datadir, 'player_give.py'), [u'give', u'put', u'drop'], class_wizard, is_ability=True)
	registry.load_verb(class_author, os.path.join(datadir, 'author_create.py'), [u"@create"], class_wizard, is_ability=True)
	registry.load_verb(class_author, os.path.join(datadir, 'author_dig.py'), [u"@dig"], class_wizard, is_ability=True)
	registry.load_verb(class_author, os.path.join(datadir, 'author_describe.py'), [u"@describe"], class_wizard, is_ability=True)
	registry.load_verb(class_author, os.path.join(datadir, 'author_tunnel.py'), [u"@tunnel"], class_wizard, is_ability=True)
	registry.load_verb(class_author, os.path.join(datadir, 'author_alias.py'), [u"@alias"], class_wizard, is_ability=True)
	registry.load_verb(class_author, os.path.join(datadir, 'author_alias-exit.py'), [u"@alias-exit"], class_wizard, is_ability=True)
	registry.load_verb(class_programmer, os.path.join(datadir, 'programmer_exec.py'), [u"@exec"], class_wizard, is_ability=True)
	registry.load_verb(class_programmer, os.path.join(datadir, 'programmer_eval.py'), [u"@eval"], class_wizard, is_ability=True)
	registry.load_verb(class_programmer, os.path.join(datadir, 'programmer_edit_verb.py'), [u"@verb"], class_wizard, is_ability=True)
	registry.load_verb(class_programmer, os.path.join(datadir, 'programmer_edit_prop.py'), [u"@prop"], class_wizard, is_ability=True)
	registry.load_verb(class_programmer, os.path.join(datadir, 'programmer_edit_obj.py'), [u"@edit"], class_wizard, is_ability=True)
	registry.load_verb(class_programmer, os.path.join(datadir, 'programmer_edit_acl.py'), [u"@acl"], class_wizard, is_ability=True)
	registry.load_verb(class_wizard, os.path.join(datadir, 'wizard_adduser.py'), [u"@adduser"], class_wizard, is_ability=True)
	registry.load_verb(class_wizard, os.path.join(datadir, 'wizard_parse.py'), [u"@parse"], class_wizard, is_ability=True)
	registry.load_verb(class_wizard, os.path.join(datadir, 'wizard_export.py'), [u"@export"], class_wizard, is_ability=True)
	registry.load_verb(class_wizard, os.path.join(datadir, 'wizard_load.py'), [u"@load"], class_wizard, is_ability=True)
	registry.load_verb(class_wizard, os.path.join(datadir, 'wizard_reload.py'), [u"@reload"], class_wizard, is_ability=True)
	
	# this verb is an example of one that uses the 'sudo' command to run
	# verb code as the owner of the verb. Note that the verb is owned by
	# 'wizard', who is the default owner of all user passwords
	registry.load_verb(class_player, os.path.join(datadir, 'player_passwd.py'), [u"@passwd"], wizard, is_ability=True)